home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS11.ADF / AmigaBasicProgs / Optimization / Plot.MSB (.txt) next >
AmigaBASIC Source Code  |  1986-08-05  |  1KB  |  82 lines

  1. '
  2. ' Optimize Your AmigaBasic Programs For Speed 
  3. '
  4. ' By Stephen R. Pietrowicz
  5. '
  6. ' Listing one - Plotting example
  7. '
  8.  
  9. DEF FNa(t) = (100/360*t)/3
  10.  
  11. '
  12. ' Draw each of the plots one at a time
  13. ' and report all times when done
  14. '
  15. CLS
  16. GOSUB SlowPlot
  17. FOR i = 1 TO 10000:NEXT i
  18.  
  19. CLS
  20. GOSUB QuickPlot
  21. FOR i = 1 TO 10000:NEXT i
  22.  
  23. CLS
  24. GOSUB QuickerPlot
  25.  
  26. LOCATE 1,1
  27. PRINT "SlowPlot:    Begin -- ";a1$;" End -- ";a2$
  28. PRINT "QuickPlot:   Begin -- ";b1$;" End -- ";b2$
  29. PRINT "QuickerPlot: Begin -- ";c1$;" End -- ";c2$
  30. END
  31.  
  32. SlowPlot:
  33. PRINT "SlowPlot"
  34. a1$ = TIME$   
  35. FOR j = 20 TO 100 STEP 20
  36.    FOR x = -150 TO -1 STEP 0.2
  37. '
  38. '     First draw right side
  39. '
  40.       y = SIN(FNa(x))/(FNa(x))*j+50
  41.       PSET (x+150,y),1
  42.    NEXT x
  43.    FOR x = 1 TO 150 STEP 0.2
  44. '
  45. '      Now draw left side
  46. '
  47.        y = SIN(FNa(x))/(FNa(x))*j+50
  48.        PSET (x+150,y),1
  49.    NEXT x
  50. NEXT j
  51. a2$ = TIME$
  52. RETURN
  53.  
  54. QuickPlot:
  55. PRINT "QuickPlot"
  56. b1$ = TIME$
  57. FOR j = 20 TO 100 STEP 20
  58.    FOR x = 1 TO 150 STEP 0.2
  59.       sy = x*0.0925926
  60.       y1 = SIN(sy)/sy*j+50
  61.       PSET (150-x,y1),1
  62.       PSET (x+150,y1),1
  63.    NEXT x
  64. NEXT j
  65. b2$ = TIME$
  66. RETURN
  67.  
  68. QuickerPlot:
  69. PRINT "QuickerPlot"
  70. c1$ = TIME$
  71. FOR x = 1 TO 150 STEP 0.2
  72.     sy = x*0.0925926
  73.     SinTemp = SIN(sy)/sy
  74.     FOR j = 20 TO 100 STEP 20
  75.        y1 = SinTemp*j+50
  76.        PSET (150-x,y1),1
  77.        PSET (x+150,y1),1
  78.     NEXT j
  79. NEXT x
  80. c2$ = TIME$
  81. RETURN
  82.